package com.fortune.rainshine.controller;

import com.fortune.rainshine.feign.service.VideoFeign;
import com.fortune.rainshinecommon.base.MsgModel;
import com.fortune.rainshinecommon.model.service.VideoTeachingModel;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * @program: rainShine
 * @description:
 * @author: tangyn
 * @create: 2019-06-29
 **/
@RestController
@RequestMapping("videoController")
public class VideoController {

    @Autowired
    private VideoFeign videoFeign;

    @ResponseBody
    @RequestMapping("/getVideoList")
    public MsgModel getVideoList(){
        List<VideoTeachingModel> list = Optional.ofNullable(videoFeign.list()).orElse(Lists.newArrayList());
        return new MsgModel(list.size(),list);
    }
}
